
{% include "base/template_head.html" %}


<div class="row">

<div class="col-lg-3 col-lg-offset-4">
    <form method="post">
        {% csrf_token %}
        <h1 class="header">启停控制</h1>
        <span style="display: none" id="show_project_server_div">
                <table id="show_project_server" class="table table-striped table-bordered table-hover" >
                    <thead>
                        <tr>
                            <th>
                                <input type='checkbox' onclick='SelectAll()' name='checkAll' id='checkAll' />
                            </th>
                            <th>项目所在服务器</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </span>

            <div>

            <div class="space-10"></div>
                <h4 class="center">请选择项目模块:</h4>
                <select onchange="return GetProjectServerIP()" name="project_name" id="project_name" data-placeholder="请选择项目模块" class="chosen-select" >
                    <option selected>=====请选择=====</option>
                    {% for each_project in project_lists %}
                    <option value="{{ each_project }}">{{ each_project }}</option>
                    {% endfor %}
                </select>
            </div>

            <div>
        <div class="control-group">
            <div class="radio">
                <label>
                    <input name="operation" type="radio" class="ace" value="stop" checked="checked">
                    <span class="lbl"> STOP </span>
                </label>
            </div>
            <div class="radio">
                <label>
                    <input name="operation" type="radio" value="start" class="ace">
                    <span class="lbl"> START </span>
                </label>
            </div>
            <div class="radio">
                <label>
                    <input name="operation" type="radio" value="restart" class="ace">
                    <span class="lbl"> RESTART </span>
                </label>
            </div>


            </div>
            </div>
        <div class="center">
                <button class="width-55  btn btn-sm btn-danger" type="submit">
                    <span class="bigger-110">提 交</span>
                </button>
            </div>

    </form>
</div>
</div>

<script type="text/javascript">
$.ajaxSetup({
    data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
function SelectAll() {
    $("input[name='serverlist']").prop("checked",$("#checkAll").is(':checked'));
}


function GetProjectServerIP(){
  var project_name=document.getElementById("project_name").value;

    if (project_name != "=====请选择=====") {
        $.ajax({
            type: "Get",
            url: "#",
            data: "project_name=" + project_name,
            dataType: "json",
            success: function (data) {
                $("#show_project_server_div").css("display", "block");
                $("#show_project_server").children("tbody").empty();
                $.each(data, function (n, value) {
                    $("#show_project_server").children("tbody").append("<tr><td name='serverlist'><input type='checkbox' value='"+value+"' name='serverlist' /></td><td>"+value+"</td></tr>");

                })
            },
            error: function (err) {
                                alert("wrong");
            }
        });

    }
}




</script>
{% include "base/template_footer.html" %}

	</body>
</html>